package com.example.basicknowledge.UI基本外形和控制;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.TextView;

import com.example.basicknowledge.R;

public class BaseUIAndControl extends AppCompatActivity implements View.OnClickListener {
    private TextView textView;

    class Button2_OnClickListener implements View.OnClickListener {
        @Override
        public void onClick(View view) {
            textView.setBackgroundColor(Color.YELLOW);
        }
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.base_ui_and_control);
        System.out.println("BaseUIAndControl onCreate");

        textView = (TextView)findViewById(R.id.textView);
        final Button button = (Button)findViewById(R.id.button);
        final Button button1 = (Button)findViewById(R.id.button2);
        final Button button2 = (Button)findViewById(R.id.button3);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                textView.setBackgroundColor(Color.RED);
            }
        });

        button1.setOnClickListener(this);

        Button2_OnClickListener button2_onClickListener = new Button2_OnClickListener();
        button2.setOnClickListener(button2_onClickListener);
    }

    @Override
    public void onClick(View view) {
        if (view.getId() == R.id.button2) {
            textView.setBackgroundColor(Color.GREEN);
        }
    }
}
